package com.cyzy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyzy.domain.bean.TOrder;
import com.cyzy.domain.dto.ResponseData;
import com.cyzy.domain.vo.TOrderVo;
import com.cyzy.mapper.TOrderMapper;
import com.cyzy.service.TOrderService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO
 *
 * @author Honarly
 * @date 2024.11.19
 */
@Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService {

    @Override
    public ResponseData selectByUserId(Integer userId, String status, Integer pageNo, Integer pageSize) {
        if (userId == null || status == null || pageNo == null || pageSize == null) {
            return ResponseData.error("参数不能为空");
        }
        List<TOrderVo> list = baseMapper.selectByUserId(userId, status, (pageNo - 1) * pageSize, pageSize);
        if (list == null || list.isEmpty()) {
            return ResponseData.success("查询订单信息为空", null, 0);
        }
        return ResponseData.success("查询订单数据成功", list, list.size());
    }
}
